package com.wei.duowan.bbs.ui.activity;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.widget.FrameLayout;

import com.wei.duowan.bbs.R;
import com.wei.duowan.bbs.model.NewsChannelBean;
import com.wei.duowan.bbs.presenter.BasePresenter;
import com.wei.duowan.bbs.ui.fragment.NewsListFragment;

import butterknife.Bind;

/**
 * 作者：赵若位
 * 时间：2019/9/28 11:41
 * 联系方式：1070138445
 * 功能：
 */
public class NewListActivity extends BaseActivity
{
    private static final String TAG = NewListActivity.class.getSimpleName();


    @Bind(R.id.container)
    FrameLayout mContainer;

    private NewsChannelBean.ChannelBean mData;


    @Override
    protected BasePresenter createPresenter()
    {
        return null;
    }

    @Override
    protected int getLayoutID()
    {
        return R.layout.activity_new_list;
    }

    @Override
    protected void initView()
    {
        mData = getIntent().getParcelableExtra(TAG);
        setFinish();
        setTitle((mData == null || TextUtils.isEmpty(mData.getTitle())) ? getString(R.string.app_name) : mData.getTitle());
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        NewsChannelBean data = new NewsChannelBean();
        data.setName((mData == null || TextUtils.isEmpty(mData.getTitle())) ? getString(R.string.app_name) : mData.getTitle());
        NewsListFragment fragment = NewsListFragment.getFragment(data);
        transaction.add(R.id.container, fragment);
        transaction.commit();
        /*主动加载数据*/
        fragment.initData();
    }


    @Override
    protected void onDestroy()
    {
        super.onDestroy();

    }
}
